import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;


public class Clazz {


	/**
	 * @param args
	 */
	public static void main(String[] args) {
		
		/*MyList<String> list = new MyList<String>();
		list.add("String0");
		list.add("String1");
		System.out.println(list.get(1));*/
	}
}

class MyList<E>{
	private int countOfElement = 0;
	private int capacity;
	private Object[] element;

	public MyList(){
		capacity = 8;
		element = new Object[capacity];
	}

	private void ensureCapasity(int minSize){
		if(minSize > capacity){
			int newSize = minSize;
			newSize = (capacity * 3)/2 + 1 ;
			if(minSize > newSize){
				newSize = minSize;
			}
			Arrays.copyOf(element, newSize);
		}
	}

	public void add(E e){
		ensureCapasity(countOfElement+1);
		element[countOfElement++] = e;
	}

	private void checkRange(int index){
		if(index < 0 || index >= countOfElement)
			try {
				throw new MyIndexOutOfBoundException("error index " + index);
			} catch (MyIndexOutOfBoundException e) {
				e.printStackTrace();
			}
	}

	public E get(int index){
		checkRange(index);
		return (E)element[index];
	}
}


class MyIndexOutOfBoundException extends Exception{
	private static final long serialVersionUID = 1L;

	MyIndexOutOfBoundException(String msg){
		System.out.println(msg);
	}


}


